
package inf3791.calendarsystem.others.components.calendar;

import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Jonas Weber
 */
class CalendarTableModel extends AbstractTableModel {

    private final static String[] weekdayAbbreviations = {"MA", "TI", "ON", "TO", "FR", "LØ", "SØ"};

    private AppointmentWrapper[][] table;
    
    public CalendarTableModel(AppointmentWrapper[][] table)
    {
        this.table = table;
    }
    
    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

    @Override
    public int getRowCount() {
        return 6;
    }

    @Override
    public int getColumnCount() {
        return 7;
    }

    @Override
    public Object getValueAt(int i, int i1) {
        return table[i][i1];
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        table[rowIndex][columnIndex] = (AppointmentWrapper) aValue;
        fireTableCellUpdated(rowIndex, columnIndex);
    }

    @Override
    public String getColumnName(int column) {
        return weekdayAbbreviations[column];
    }
    
    void doUpdateEvent()
    {
        fireTableDataChanged();
    }
}
